include_directories(${CMAKE_HOME_DIRECTORY})

include(CTest)

enable_testing()

add_custom_target(run_examples COMMAND ${CMAKE_CTEST_COMMAND} -VV -C ${CMAKE_CFG_INTDIR})

macro(add_sample name)
    add_executable(${name} ${name}.cpp)
    target_link_libraries(${name} yap)
    add_test(${name} ${CMAKE_CURRENT_BINARY_DIR}/${name})
    if (clang_on_linux)
        target_link_libraries(${name} c++)
    endif ()
endmacro()

add_sample(minimal)
add_sample(hello_world)
add_sample(hello_world_redux)
add_sample(calc1)
add_sample(calc2a)
add_sample(calc2b)
add_sample(calc3)
add_sample(lazy_vector)
add_sample(tarray)
add_sample(vec3)
add_sample(vector)
add_sample(mixed)
add_sample(map_assign)
add_sample(future_group)
add_sample(transform_terminals)
add_sample(pipable_algorithms)
if (constexpr_if_define STREQUAL "-DBOOST_NO_CONSTEXPR_IF=0")
    add_sample(let)
    add_sample(self_evaluation)
endif ()

add_executable(autodiff autodiff_example.cpp)
add_dependencies(autodiff autodiff_library)
target_link_libraries(autodiff yap boost autodiff_library)
if (clang_on_linux)
    target_link_libraries(autodiff c++)
endif ()
